package org.dprojects.iwebshare.ui.manager;

import org.dprojects.iwebshare.main.iWebShareApplication;
import org.dprojects.iwebshare.ui.layout.LayoutManager;

import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.Runo;

public class UiManagerImpl implements UiManager {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7933076600556961884L;
	
	private LayoutManager layoutManager;	

	public UiManagerImpl(LayoutManager layoutManager) {
		this.layoutManager=layoutManager;
	}
	
	
	public void createUi() {
		
		iWebShareApplication.getInstance().setTheme(Runo.themeName());
		
		VerticalLayout root = new VerticalLayout();
        root.setMargin(true);
        root.setSizeFull();
		Window main = new Window("Testv Application",root);
		
		iWebShareApplication.getInstance().setMainWindow(main);
		
		main.setContent(getLayoutManager().getMainLayout());
		
		/*
		VerticalLayout root = new VerticalLayout();
        root.setMargin(true);
        root.setSizeFull();
		Window main = new Window("Testv Application",root);
		parent.setMainWindow(main);
		
		Label title = new Label("Vaadin Runo Theme");
        title.addStyleName(Runo.LABEL_H1);
        title.setSizeUndefined();
        root.addComponent(title);
        root.setComponentAlignment(title, Alignment.TOP_CENTER);
        
        final HorizontalSplitPanel split = new HorizontalSplitPanel();
        split.setStyleName(Runo.SPLITPANEL_REDUCED);
        split.setSplitPosition(1, Sizeable.UNITS_PIXELS);
        split.setLocked(true);
        root.addComponent(split);
        root.setExpandRatio(split, 1);
        
        Panel left = new Panel("Example Sidebar");
        left.setSizeFull();
        split.setFirstComponent(left);

        Accordion accordion = new Accordion();
        accordion.setSizeFull();
        left.setContent(accordion);

        Tree tree=new Tree();
        tree.setContainerDataSource(new KalelFilesystemContainer(new File("/"),false));
        
        accordion.addTab(new Label(""), "Preferences", null);
        accordion.addTab(new Label(""), "Quick Search", null);
        accordion.addTab(tree, "Tree", null);
        
        TabSheet right = new TabSheet();
        right.setSizeFull();
        // right.addStyleName(Runo.TABSHEET_SMALL);
        split.setSecondComponent(right);
       
        split.setSplitPosition(25, Sizeable.UNITS_PERCENTAGE);
        split.setLocked(false);
        
        */
	}

	public LayoutManager getLayoutManager() {
		return layoutManager;
	}
	
	public void setLayoutManager(LayoutManager layoutManager) {
		this.layoutManager = layoutManager;
	}

}
